import 'package:demo202112/CustomNaviAnimation/wy_fade_route.dart';
import 'package:demo202112/utils/common_appbar.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

/// @Author wywinstonwy
/// @Date 2022/1/13 8:12 上午
/// @Description: 

class MyCustomAmniatonPageA extends StatefulWidget {
  const MyCustomAmniatonPageA({Key? key}) : super(key: key);

  @override
  _MyCustomAmniatonPageAState createState() => _MyCustomAmniatonPageAState();
}

class _MyCustomAmniatonPageAState extends State<MyCustomAmniatonPageA> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: getAppBar('自定义导航跳转动画A'),
      body: Column(children: [
        ElevatedButton(onPressed: (){
          Navigator.push(context, CupertinoPageRoute(
              builder: (context)=>const MyCustomAmniatonPageB()
          ));
        },child: const Text('转场动画-CupertinoPageRoute'),),

        Container(child: ElevatedButton(onPressed: (){
          Navigator.push(context,
              PageRouteBuilder(
                transitionDuration: const Duration(milliseconds: 500),//动画执行时间为500毫秒
                  pageBuilder: (BuildContext context,Animation<double> animation,Animation secondaryAnimation){
                    return FadeTransition(opacity: animation,child: const MyCustomAmniatonPageB(),);
                  }));
        },child: const Text('自定义转场动画渐变效果'),),),

        ElevatedButton(onPressed: (){
          Navigator.push(context, FadeRoute(builder: (context) {
            return const MyCustomAmniatonPageB();
          }));


        },child: const Text('自定义PageRoute转场动画渐变效果'),),

      ],)
    );
  }
}


class MyCustomAmniatonPageB extends StatefulWidget {
  const MyCustomAmniatonPageB({Key? key}) : super(key: key);

  @override
  _MyCustomAmniatonPageBState createState() => _MyCustomAmniatonPageBState();
}

class _MyCustomAmniatonPageBState extends State<MyCustomAmniatonPageB> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: getAppBar('自定义导航跳转动画B'),
    );
  }
}